
<div class="row">
    <div class="col-sm-2">
        <button type="button" onClick="upImage_{{ $uEditorStatic }}()" class="btn btn-info">图片上传</button>
    </div>
    <div class="col-sm-10 picture-list" id="picture-list-{{ $uEditorStatic }}">
        @if($maxNumber == 1)
            <div class="col-sm-3 picture-info">
                <img class="img-responsive" src="{{ get_upload_url(get_value($inputValue, 'url', '')) }}" alt="Photo">
                <input type="hidden" name="{{ $inputName }}[url]" id="upload-picture-{{ $uEditorStatic }}-url" value="{{ get_value($inputValue, 'url', '') }}" title="图片地址">
                <input type="hidden" name="{{ $inputName }}[id]" id="upload-picture-{{ $uEditorStatic }}-id" value="{{ get_value($inputValue, 'id', 0) }}" title="图片编号">
            <!--<textarea class="form-control" name="{{ $inputName }}[desc]" title="图片描述">{{ get_value($inputValue, 'desc', '') }}</textarea>-->
            </div>
        @else
            @foreach($inputValue as $key=>$value)
                <div class="col-sm-3 picture-info">
                    <img class="img-responsive" src="{{ get_upload_url(get_value($value, 'url', '')) }}" alt="Photo">
                    <input type="hidden" name="{{ $inputName }}[{{ $key }}][url]" value="{{ get_value($value, 'url', '') }}" title="图片地址">
                    <input type="hidden" name="{{ $inputName }}[{{ $key }}][id]" value="{{ get_value($value, 'id', 0) }}" title="图片编号">
                    <textarea class="form-control" name="{{ $inputName }}[{{ $key }}][desc]" title="图片描述" placeholder="请输入图片描述信息">{{ get_value($value, 'desc', '') }}</textarea>

                    <button type="button" class="btn btn-box-tool" onclick="removePicture(this)"><i class="fa fa-times"></i></button>
                </div>
            @endforeach

        <!--<div class="col-sm-3 picture-info">
                <img class="img-responsive" src="{{ asset('img-lte/photo1.png') }}" alt="Photo">
                <input type="hidden" name="{{ $inputName }}[0][url]" value="" title="图片地址">
                <input type="hidden" name="{{ $inputName }}[0][id]" value="" title="图片编号">
                <textarea class="form-control" name="{{ $inputName }}[0][desc]" title="图片描述" placeholder="请输入图片描述信息"></textarea>
            </div>-->

        @endif
        <div style="clear: both;"></div>
    </div>
</div>
<?php static $static = 0; $static++; ?>
@if($static == 1)
<style>
    .picture-list .picture-info {width:170px; padding-top: 5px;}
    .picture-list .picture-info textarea {resize:none;}
    .picture-list .btn-box-tool {position: absolute; top:0; right: 0;}
    .img-responsive {display: initial; height: 120px; width: auto;}
</style>
@endif

@if($uEditorStatic==1)
    <script type="text/javascript" charset="utf-8" src="{{ asset('plugins/ueditor/1.4.3/ueditor.config.js') }}"></script>

    <script type="text/javascript" charset="utf-8" src="{{ asset('plugins/ueditor/1.4.3/ueditor.all.js') }}"></script>

    <script type="text/javascript" src="{{ asset('plugins/ueditor/1.4.3/lang/zh-cn/zh-cn.js') }}"></script>

    <script>
        window.UEDITOR_HOME_URL = "{{ asset('plugins/ueditor/1.4.3') }}";
    </script>
@endif

<script type="text/javascript" id="ueditor-upload-{{ $uEditorStatic }}"></script>

<script>
    var maxNumber_{{ $uEditorStatic }} = "{{ $maxNumber }}";
    var inputName_{{ $uEditorStatic }} = "{{ $inputName }}";

    //实例化编辑器
    var ueditorUpload_{{ $uEditorStatic }} = UE.getEditor('ueditor-upload-{{ $uEditorStatic }}', {
        autoHeightEnabled:false
    });
    ueditorUpload_{{ $uEditorStatic }}.ready(function ()
    {
        ueditorUpload_{{ $uEditorStatic }}.hide();//隐藏编辑器

        //监听图片上传
        ueditorUpload_{{ $uEditorStatic }}.addListener('beforeInsertImage', function (t,arg) {
            if (maxNumber_{{ $uEditorStatic }} == 1) {
                $("#upload-picture-{{ $uEditorStatic }}-url").parent().children('img').attr('src', arg[0].src);
                $("#upload-picture-{{ $uEditorStatic }}-url").val(arg[0].src);
            } else {
                var html = '';
                var number = $("#picture-list-{{ $uEditorStatic }} .picture-info").length;
                $.each(arg, function (key, value) {
                    var n = number + key;
                    html += '<div class="col-sm-3 picture-info">\n' +
                        '                <img class="img-responsive" src="'+value.src+'" alt="Photo">\n' +
                        '                <input type="hidden" name="'+inputName_{{ $uEditorStatic }}+'['+n+'][url]" value="'+value.src+'" title="图片地址">\n' +
                        '                <input type="hidden" name="'+inputName_{{ $uEditorStatic }}+'['+n+'][id]" value="0" title="图片编号">\n' +
                        '                <textarea class="form-control" name="'+inputName_{{ $uEditorStatic }}+'['+n+'][desc]" title="图片描述" placeholder="请输入图片描述信息">'+value.alt+'</textarea>\n' +
                        '                <button type="button" class="btn btn-box-tool" onclick="removePicture(this)"><i class="fa fa-times"></i></button>\n'+
                        '</div>';
                });
                $("#picture-list-{{ $uEditorStatic }}").append(html);
            }
        });
    });


        //弹出图片上传的对话框
        function upImage_{{ $uEditorStatic }}() {
            myImage = ueditorUpload_{{ $uEditorStatic }}.getDialog("insertimage");
            myImage.open();
        }


        if(!removePicture || typeof(removePicture) != "function") {
            function removePicture(obj) {
                $(obj).parent().remove();
            }
        }
        
</script>